import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 解决Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location:
//使用编程式路由实现跳转的时候，多次执行会抛出NavigationDuplicated的警告错误是因为"vue-router"3版本之后 底层引入了promise,而通过声明式导航没有出现此类问题是因为vue-router底层已经处理好了。
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  // 路由
  routes: [
    {
      // 登录页
      path: '/',
      name: 'Login',
      // 这里有多个首页可以选择,可用的有 Login2.vue
      component: () => import('@/components/login/Login3.vue')
    },
    {
      // 登录的参数页面
      path: '/LoginForm',
      name: 'LoginForm',
      component: () => import('@/components/login/LoginForm.vue')
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('@/components/login/Register.vue'),
    },
    {
      path: '/register2',
      name: 'Register2',
      component: () => import('@/components/login/Register2.vue'),
    },
    {
      path: '/403',
      name: '403',
      component: () => import('@/components/exception/403.vue')
    },
    {
      path: '/404',
      name: '404',
      component: () => import('@/components/exception/404.vue'),
    },
    {
      path: '/500',
      name: '500',
      component: () => import('@/components/exception/500.vue'),
    },
    {
      path: '/toVideoPlaybackNoBorder',
      name: 'toVideoPlaybackNoBorder',
      component: () => import('@/components/toolbox/VideoPlaybackNoBorder.vue'),
    },
    {
      path: '/toKnowledgeDetailed',
      name: 'toKnowledgeDetailed',
      component: () => import('@/components/knowledgeble/OpsKnowledgeDetailed.vue'),
    },
    {
      // 系统首页
      path: '/home',
      name: 'Home',
      component: () => import('@/components/home/Home.vue'),
      // 默认页面
      redirect: '/index',
      // 用于父页面进行切换的子路由
      children: [
        {
          // 首页的第一个页面
          path: '/index',
          name: 'Index',
          component: () => import("@/components/home/Index.vue")
        },
        {
          path: '/toAuthorityList',
          component: () => import("@/components/authority/AuthorityList.vue")
        },
        {
          path: '/toUnfinished',
          component: () => import("@/components/sys/Unfinished.vue")
        },
        {
          path: '/toDeptList',
          component: () => import("@/components/authority/DeptList.vue")
        },
        {
          path: '/toUserList',
          component: () => import("@/components/authority/UserList.vue")
        },
        {
          path: '/toRoleList',
          component: () => import("@/components/authority/RoleList.vue")
        },
        {
          path: '/toAppLayout',
          component: () => import("@/components/project/AppLayout.vue")
        },
        {
          path: '/toAppList',
          component: () => import("@/components/project/AppList.vue")
        },
        {
          path: '/toThirdPartyLayout',
          component: () => import("@/components/site/OpsThirdPartyLayout.vue")
        },
        {
          path: '/toComponentList',
          component: () => import("@/components/project/ComponentList.vue")
        },
        {
          path: '/toSiteList',
          component: () => import("@/components/site/OpsSiteList.vue")
        },
        {
          path: '/toSiteLayout',
          component: () => import("@/components/site/SiteLayout.vue")
        },
        {
          path: '/toComponentLayout',
          component: () => import("@/components/project/ComponentLayout.vue")
        },
        {
          path: '/toComputerServerList',
          component: () => import("@/components/site/ComputerServerList.vue")
        },
        {
          path: '/toOpsDeployAppList',
          component: () => import("@/components/deploy/OpsDeployAppList.vue")
        },
        {
          path: '/toPersonalPasswordList',
          component: () => import("@/components/box/OpsPersonalPasswordList.vue")
        },
        {
          path: '/toDict',
          component: () => import("@/components/sys/DictGroupList.vue")
        },
        {
          path: '/toAboutUs',
          component: () => import("@/components/sys/AboutUs.vue")
        },
        {
          path: '/toSysConfigList',
          name: 'config',
          component: () => import('@/components/sys/OpsSysConfigList.vue'),
        },
        {
          path: '/toThirdPartyList',
          component: () => import("@/components/thirdParty/OpsThirdPartyList.vue")
        },
        {
          path: '/toThirdPartyUserList',
          component: () => import("@/components/thirdParty/OpsThirdPartyUserList.vue")
        },
        {
          path: '/toProductList',
          component: () => import("@/components/project/ProductList.vue")
        },
        {
          path: '/toProductLayout',
          component: () => import("@/components/project/ProductLayout.vue")
        },
        {
          path: '/toToolList',
          component: () => import("@/components/tool/OpsToolList.vue")
        },
        {
          path: '/toNetEnvList',
          component: () => import("@/components/site/NetEnvList.vue")
        },
        {
          path: '/toVideoPlayback',
          name: 'toVideoPlayback',
          component: () => import('@/components/toolbox/VideoPlayback.vue'),
        },
        {
          path: '/toDruid',
          name: 'toDruid',
          component: () => import('@/components/sys/Druid.vue'),
        },
        {
          path: '/toProductQuestionList',
          name: 'toProductQuestionList',
          component: () => import('@/components/knowledgeble/OpsProductQuestionList.vue'),
        },
        {
          path: '/toOpsKnowledgeList',
          name: 'toOpsKnowledgeList',
          component: () => import('@/components/knowledgeble/OpsKnowledgeList.vue'),
        },
        {
          path: '/toFileStorageList',
          name: 'toFileStorageList',
          component: () => import('@/components/sys/OpsDromaraFileStorageList.vue'),
        },
        {
          path: '/toComputerList',
          name: 'toComputerList',
          component: () => import('@/components/sys/ComputerList.vue'),
        },
        {
          path: '/toAccountList',
          name: 'toAccountList',
          component: () => import('@/components/sys/AccountList.vue'),
        },
        {
          path: '/toCommonFile',
          name: 'toCommonFile',
          component: () => import('@/components/sys/CommonFile.vue'),
        },
      ],
    },


    // {
    //   path: '/home',
    //   name: 'Home',
    //   component: Home,
    //   children:[
    //     {
    //       path: '/initHome',
    //       name: 'InitHome',
    //       component: InitHome
    //     },
    //     {
    //       path: '/dataSourceManagement',
    //       name: 'DataSourceManagement',
    //       component: DataSourceManagement
    //     },
    //   ]
    // },
    // {
    //   path: '/login',
    //   name: 'Login',
    //   component: LoginForm,
    // },
  ]
})
